﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;

namespace SPQueryToSql.ApplicationObjects.CAML
{
    internal class GroupBy
    {
        public List<FieldRef> FieldRefs;

        public GroupBy(XContainer element)
        {
            FieldRefs = new List<FieldRef>();
            foreach (var child in element.Elements())
            {
                FieldRefs.Add(new FieldRef(child));
            }
        }

        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("<GroupBy>");
            sb.Append(Environment.NewLine);
            foreach (var fr in FieldRefs)
            {
                sb.Append(fr.ToString(1));
            }
            sb.Append("</GroupBy>");
            return sb.ToString();
        }
    }
}
